package com.nf.health.app.activity.miansearch.impl;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.nf.health.app.R;
import com.nf.health.app.customview.CircleImageView;
import com.nf.health.app.customview.MyFlowLayout;
import com.nf.health.app.inquiry.bean.DoctorDetailBean;
import com.nf.health.app.inquiry.docdetail.DocDetailActivity;
import com.nf.health.app.models.SearchMainDocBean;
import com.nf.health.app.utils.ActivityUtils;
import com.nf.health.app.utils.GetToast;
import com.nf.health.app.utils.ViewUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Jason on 2016/9/28.
 */
public class SearchMainViewHolder   extends RecyclerView.ViewHolder implements View.OnClickListener {
    @Bind(R.id.iv_personal_doc_item_serch)
    public CircleImageView iv_personal_doc_item_serch;

    @Bind(R.id.tv_item_doc_name_serch)//医生姓名
    public TextView tv_item_doc_name_serch;

    @Bind(R.id.tv_item_doc_address_serch)
    TextView tv_item_doc_address_serch;//医院名称

    @Bind(R.id.tv_assocital_num_serch)
    TextView tv_assocital_num_serch;//已签约225人"

    @Bind(R.id.tv_item_doc_type_serch)
    TextView tv_item_doc_type_serch;//医生类别

    @Bind(R.id.rl_marchen)
    RelativeLayout rl_marchen;//点击事件


    private Activity cnt;
    public SearchMainViewHolder(View itemView, Activity cnt) {
        super(itemView);
        ButterKnife.bind(this, itemView);
        this.cnt = cnt;

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case  R.id.ll_shouqi_icon_doc:
            case  R.id.tv_query_doc_detail:
                GetToast.useString(cnt, "成功啦");
                break;
        }
    }

    public void loadData(final SearchMainDocBean searchMainDocBean){
        if(searchMainDocBean == null){
            return ;
        }
        Glide.with(cnt)
                .load(searchMainDocBean.getHimg())
                .placeholder(R.drawable.default_head)
                .into(iv_personal_doc_item_serch);
        tv_assocital_num_serch.setText(TextUtils.isEmpty(searchMainDocBean.getHospital()) ? "已签约0人" : "已签约" + searchMainDocBean.getNick() + "人");
        tv_item_doc_name_serch.setText(TextUtils.isEmpty(searchMainDocBean.getNick()) ? "未填写" : searchMainDocBean.getNick());
        tv_item_doc_address_serch.setText(TextUtils.isEmpty(searchMainDocBean.getHospitalname()) ? "未填写" : searchMainDocBean.getHospitalname());
        tv_item_doc_type_serch.setText(searchMainDocBean.getDepartment() + " | " + searchMainDocBean.getProfessional());
        rl_marchen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle docDetailBundle = new Bundle();
                docDetailBundle.putString(DocDetailActivity.DOCTORID, searchMainDocBean.getDoctorid());
                ActivityUtils.showActivity(cnt, DocDetailActivity.class, docDetailBundle);
            }
        });
    }
}
